#include "Protocol.hpp"

class ProtocolRegisterReq : public Protocol
{
public:
    ProtocolRegisterReq()
        : Protocol(Type::RegisterReq)
    {
    }

    virtual std::string serialize() override
    {
        Json::Value root;
        Json::FastWriter writer;
        root["type"] = _type;
        root["username"] = username;
        root["userid"] = userid;
        root["password"] = password;
        root["head"] = head;

        return writer.write(root);
    }
    virtual void deserialize(const Json::Value &root) override
    {
        _type = (Protocol::Type)root["type"].asInt();
        username = root["username"].asString();
        userid = root["userid"].asString();
        password = root["password"].asString();
        head = root["head"].asString();
    }

    std::string getUsername()
    {
        return username;
    }

    std::string getPassword()
    {
        return password;
    }

    std::string getHead()
    {
        return head;
    }

    void setUsername(std::string username)
    {
        this->username = username;
    }

    void setPassword(std::string password)
    {
        this->password = password;
    }

    std::string getUserid()
    {
        return userid;
    }

    void setUserid(const std::string &userid)
    {
        this->userid = userid;
    }

    void setHead(const std::string &head)
    {
        this->head = head;
    }

private:
    std::string username;
    std::string userid;
    std::string password;
    std::string head;
};

// class ProtocolRegisterResp : public Protocol
// {
// public:
//     ProtocolRegisterResp()
//         : Protocol(Type::RegisterResp)
//     {
//     }

//     virtual std::string serialize() override
//     {
//         Json::Value root;
//         Json::FastWriter writer;
//         root["type"] = _type;
//         root["code"] = code;

//         return writer.write(root);
//     }
//     virtual void deserialize(const Json::Value &root) override
//     {
//         _type = (Protocol::Type)root["type"].asInt();
//         code = root["code"].asInt();
//     }

//     void setCode(int code)
//     {
//         this->code = code;
//     }

//     int getCode()
//     {
//         return code;
//     }

// private:
//     int code;
// };